<template>
  <div>
    <detail-banner :detail="detail"></detail-banner>
    <detail-header></detail-header>
    <detail-list :list="list"></detail-list>
    <div class="content"></div>
  </div>
</template>

<script>
  import DetailBanner from './components/Banner'
  import DetailHeader from './components/Header'
  import DetailList from './components/List'
  import axios from 'axios'

  export default {
    name: 'Detail',
    components: {
      DetailBanner,
      DetailHeader,
      DetailList
    },
    data () {
      return {
        list: [],
        detail: {}
      }
    },
    activated: function () {
      console.log('activated' + 'Detail')

    },
    methods: {
      getDetail: function () {
        // console.log('Detail' + this.$route.params.id)
        axios.get('static/mock/detail.json', {
          params: {
            id: +this.$route.params.id
          }
        }).then(this.handleDetails)
      },
      handleDetails: function (res) {
        res = res.data
        console.log(res)
        if (res.ret && res.data) {
          this.list = res.data.categoryList
          this.detail = res.data
        }
      }
    },
    mounted: function () {
      console.log('mounted' + 'Detail')
      this.getDetail()
    }
  }
</script>

<style scoped>
  .content {
    height: 50rem;
  }
</style>
